package com.doit.demo04;

public class tickt implements Runnable {
    private int i=100;
    private Object obj = new Object();

    @Override
    public void run() {
        while(true)
        {
//            synchronized (obj){
            synchronized (this){
                if (i > 0) {
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(Thread.currentThread().getName() + "正在卖票" + i);
                    i--;
                }
                else
//                    System.exit(0);
                break;
            }
        }
    }
}
